﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for clsTaoDeThi
/// </summary>
public class clsTaoDeThi
{
    DataClassesDataContext obj_taodt = new DataClassesDataContext();
    public clsTaoDeThi()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    private string MaDT;

    public string MaDT1
    {
        get { return MaDT; }
        set { MaDT = value; }
    }


    public List<clsTaoDeThi> danhsachdt()
    {
        var dethi = (from p in obj_taodt.tbl_DETHIs
                      select new clsTaoDeThi{ 
                        MaDT=p.MaDT
                     }).ToList();
        return dethi;
    }

    public void TaoDeThi(string madt, string maqt)
    {


        int kho = (from p in obj_taodt.tbl_QUYTACDETHIs
                   where p.MaQT == maqt
                   select p.Kho).Single();
        obj_taodt.sp_LayRDCH(kho, madt, "Kho");

        int tb = (from p in obj_taodt.tbl_QUYTACDETHIs
                  where p.MaQT == maqt
                  select p.TB).Single();
        obj_taodt.sp_LayRDCH(tb, madt, "TB");

        int de = (from p in obj_taodt.tbl_QUYTACDETHIs
                  where p.MaQT == maqt
                  select p.De).Single();
        obj_taodt.sp_LayRDCH(de, madt, "De");

        obj_taodt.SubmitChanges();
    }
    public void ThemDeThi(string madt, string maqt, string mamon, string tendt)
    {
        tbl_DETHI dt = new tbl_DETHI();
        dt.MaDT = madt;
        dt.MaQT = maqt;
        dt.MaMon = mamon;
        dt.TenDeThi = tendt;
        obj_taodt.tbl_DETHIs.InsertOnSubmit(dt);
        obj_taodt.SubmitChanges();
 
    }
    
}
